package com.xigua.字符串;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/2/210:53
 */
public class _2000_反转单词前缀 {

    public static void main(String[] args) {

    }

    public String reversePrefix(String word, char ch) {
        int index = word.indexOf(ch);
        if (index < 0) return word;
        char[] chars = word.toCharArray();
        int left = 0; int right = index;
        while (left<right){
            char temp = chars[left];
            chars[left] = chars[right];
            chars[right] = temp;
            left++;
            right--;
        }
        return new String(chars);

    }

}
